<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="common/head :: htmlhead">
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">博物馆信息</div>
                <div class="layui-card-body">
                    <table id="info_table" lay-filter="info_table"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="table_operate">
    <a class="layui-btn layui-btn-xs" lay-event="cangpin">藏品</a>
    <a class="layui-btn layui-btn-xs" lay-event="ZFzhichi">政府支持情况</a>
    <a class="layui-btn layui-btn-xs" lay-event="xiangqing">详情</a>
    <a shiro:hasPermission="memberManage" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script>
    layui.use(['table','element'],function () {
        var table = layui.table
            ,element = layui.element;
        table.render({
            elem: '#info_table'
            ,url: '/getmemList/bwg'
            ,method : 'post'
            ,toolbar: true
            // ,defaultToolbar: ['filter', 'print']
            ,cellMinWidth: 80
            ,page: true
            ,cols: [
                [
                    {type:'checkbox', fixed: 'left'},
                    {field: 'name', title: '名称'},
                    {field: 'industrytype', title: '所属工业类别'},
                    {field: 'address', title: '地址'},
                    {field: 'creattime', title: '建立时间',
                        templet:function (row){
                            return createTime(row.creattime);}
                    },
                    {fixed: 'right', title:'操作', toolbar: '#table_operate', width:'25%'}
                ]
            ]
        });

        table.on('tool(info_table)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('确定删除此博物馆信息？删除后不可恢复！', function(index){
                    $.ajax({
                        url:"/deleteinfo/bwg",
                        async: false,
                        type:"POST",
                        dataType: "text",
                        data:data,
                        success: function(data){
                            if(data==="error"){
                                layer.msg('删除失败！', {icon: 2});
                                layer.close(index);
                            }else if(data==="success"){
                                layer.msg('删除成功！', {icon: 1});
                                location.reload()
                            }
                        }
                    });
                    layer.close(index);
                });
            } else if(obj.event === 'xiangqing'){
                var url='/xiangqing?type=bwg&page=sjck&id='+data.id;
                top.layui.index.openTabsPage(url, "博物馆详细信息");
            } else if(obj.event === 'cangpin'){
                var url='/xiangqing?type=cangpinlist&id='+data.id+'&name='+data.name;
                top.layui.index.openTabsPage(url, "藏品");
            } else if(obj.event === 'ZFzhichi'){
                var url='/xiangqing?type=ZFzhichilist&id='+data.id+'&name='+data.name;
                top.layui.index.openTabsPage(url, "政府支持情况");
            }
        });

    });

    function createTime(v){
        var date = new Date(v);
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        m = m<10?'0'+m:m;
        var d = date.getDate();
        d = d<10?("0"+d):d;
        var h = date.getHours();
        h = h<10?("0"+h):h;
        var M = date.getMinutes();
        M = M<10?("0"+M):M;
        var str = y+"-"+m+"-"+d+" "+h+":"+M;
        return str;
    }
</script>
</body>
</html>
